<%@ page contentType="text/xml;charset=utf-8"
	import="java.sql.Connection, java.sql.PreparedStatement, java.sql.ResultSet
	, git.bankview.sl.db.DBConnectionFactory
	, git.bankview.wl.auth.userGroups.TransCheck"
%><%@ include file="/jsp/inc/pageUtils.jsp"
%><% response.addHeader("Cache-Control", "no-cache"); %>
<jsp:useBean id="oLogon" class="git.bankview.wl.bean.LogonBean" scope="session" />
<trans>
<%
	//TransCheck.check(oLogon.getUsername(), "90060", 1);
	String transid = request.getParameter("transid");
	Connection conn = DBConnectionFactory.getCoreConnection();
	try
	{
		PreparedStatement psAuth = conn.prepareStatement("select r.*, rt.methodid from inforole r, roletrans rt where (rt.transid = ? and r.roleid = rt.roleid) order by r.roleid, rt.methodid");
		try
		{
			PreparedStatement ps = conn.prepareStatement("select * from infotrans where transid=?");
			try
			{
				ps.setString(1, transid);
				ResultSet rs = ps.executeQuery();
				try
				{
					while (rs.next())
					{
						transid = rs.getString("transid").trim();
						String translabel = rs.getString("translabel").trim();
						String ptransid = rs.getString("ptransid").trim();
	%>
		<tran id="<%=transid%>" pid="<%=ptransid%>">
			<translabel><![CDATA[<%=translabel%>]]></translabel>
			<roletrans>
<%
						psAuth.setString(1, transid);
						ResultSet rsAuth = psAuth.executeQuery();
						
						try
						{
							String lastRoleid = null;
							while (rsAuth.next())
							{
								String roleid = rsAuth.getString("roleid").trim();
								String rolelabel = rsAuth.getString("rolelabel").trim();
								String roledesc = rsAuth.getString("roledesc").trim();
								int statuscode = rsAuth.getInt("statuscode");
								int methodid = rsAuth.getInt("methodid");
								
								if (!roleid.equals(lastRoleid))
								{
									if (null != lastRoleid)
									{
%>
					</methods>
				</roletran>
<%									}
%>
				<roletran id="roleid">
					<rolelabel><![CDATA[<%=rolelabel%>]]></rolelabel>
					<roledesc><![CDATA[<%=roledesc%>]]></roledesc>
					<!-- method: (0, enabled; 1, disabled) -->
					<methods>
<%								}
%>
						<method id="<%=methodid%>"><%=statuscode%></method>
<%
								lastRoleid = roleid;							
							} // end of while(rsAuth.next())
								
							if (null != lastRoleid)
							{
%>
					</methods>
				</roletran>
<%							}
						}
						finally
						{
							rsAuth.close();
						}
%>			</roletrans>
	</tran>
<%
					}
				}
				finally
				{
					rs.close();
				}
			}
			finally
			{
				ps.close();
			}
		}
		finally
		{
			psAuth.close();
		}
%>	<roles>
<%
		psAuth = conn.prepareStatement("select * from inforole order by roleid");
		try
		{
			ResultSet rs = psAuth.executeQuery();
			try
			{
				while(rs.next())
				{
%>		<role id="<%=rs.getString("roleid").trim()%>"><![CDATA[<%=rs.getString("rolelabel").trim()%>]]></role>
<%
				}
			}
			finally
			{
				rs.close();
			}
		}
		finally
		{
			psAuth.close();
		}
%>	</roles>
<%
	}
	finally
	{
		conn.close();
	}
	%>
</trans>
